Add profile file location management with policy support and rename folder location properties#3340
Conversation
…older location properties Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds profile folder location management (user-configurable with restart + admin policy override) analogous to the existing settings folder location feature, and renames policy/local-settings JSON properties to consistently follow the Section_SettingName convention.
Changes:
- Implement policy/custom/default resolution + validation for the profiles folder path.
- Update the Profiles settings UI to allow editing/browsing/drag-drop, with policy/portable-mode disabling and restart-on-change flows.
- Rename policy/local-settings JSON property names (
SettingsFolderLocation→Settings_FolderLocation,ProfilesFolderLocation→Profiles_FolderLocation) and update docs/examples accordingly.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| Website/docs/system-wide-policies.md | Updates policy example JSON key for settings folder location. |
| Website/docs/settings/settings.md | Updates documented policy property name for settings folder location. |
| Website/docs/settings/profiles.md | Documents new profiles folder location system-wide policy with examples. |
| Website/docs/changelog/next-release.md | Adds changelog entries for new profiles folder location capability/policy. |
| Source/NETworkManager/Views/SettingsProfilesView.xaml.cs | Adds drag/drop handlers for the profiles location textbox. |
| Source/NETworkManager/Views/SettingsProfilesView.xaml | Reworks the Profiles location UI (editable path, browse button, policy/portable indicators, change/restore actions). |
| Source/NETworkManager/ViewModels/SettingsSettingsViewModel.cs | Updates references to renamed settings policy/local-settings property. |
| Source/NETworkManager/ViewModels/SettingsProfilesViewModel.cs | Adds Profiles location state + commands for browse/change/restore with restart flow. |
| Source/NETworkManager.Settings/config.json.example | Updates example config to new key names and adds profiles folder location key. |
| Source/NETworkManager.Settings/SettingsManager.cs | Renames settings folder location policy/local-settings references + log messages. |
| Source/NETworkManager.Settings/SettingsInfo.cs | Adds persisted user setting for custom profiles folder location. |
| Source/NETworkManager.Settings/PolicyManager.cs | Logs new policy property names (settings + profiles). |
| Source/NETworkManager.Settings/PolicyInfo.cs | Renames settings policy JSON key and adds profiles policy JSON key. |
| Source/NETworkManager.Settings/LocalSettingsInfo.cs | Renames local-settings property for settings folder location. |
| Source/NETworkManager.Profiles/ProfileManager.cs | Implements policy/custom/default resolution + validation for profiles folder location. |
| Source/NETworkManager.Localization/Resources/Strings.resx | Adds localized strings for profiles location change/restore confirmation dialogs. |
| Source/NETworkManager.Localization/Resources/Strings.Designer.cs | Updates designer for the new localization keys. |
Files not reviewed (1)
- Source/NETworkManager.Localization/Resources/Strings.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….com/BornToBeRoot/NETworkManager into copilot/add-profile-file-location-ui
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 22 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- Source/NETworkManager.Localization/Resources/Strings.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| /// <summary> | ||
| /// Prompts the user to confirm and then changes the location of the application's settings folder. | ||
| /// Prompts the user to confirm and then changes the location of the profiles folder. |
There was a problem hiding this comment.
The XML doc comment says this method changes the location of the profiles folder, but this is the Settings view model and the dialog/message targets the settings folder. Please update the comment to avoid confusion for future maintenance.
| /// Prompts the user to confirm and then changes the location of the profiles folder. | |
| /// Prompts the user to confirm and then change the location of the settings folder. |
There was a problem hiding this comment.
Fixed in a73415c — updated the doc comment to say "settings folder".
| // Set new location in SettingsInfo | ||
| SettingsManager.Current.Profiles_FolderLocation = Location; | ||
|
|
||
| // Restart the application | ||
| (Application.Current.MainWindow as MainWindow)?.RestartApplication(); |
There was a problem hiding this comment.
Changing SettingsManager.Current.Profiles_FolderLocation here immediately changes what ProfileManager.GetProfilesFolderLocation() returns. During shutdown (triggered by RestartApplication()), ProfileManager.Save() uses GetProfilesFolderLocation() to create the profiles directory and to decide the backup folder, but still writes to LoadedProfileFile.Path (old path). This can create backups/directories in the new location while writing the profile file in the old location. Consider saving/unloading profiles before flipping the setting, or deferring application of the new location until next startup (similar to how the settings-location change avoids unintended writes).
There was a problem hiding this comment.
@copilot So ProfileManager.Save() before SettingsManager.Current.Profiles_FolderLocation = Location; would fix it? If yes, fix it. The profile will not be changed between the SettingsManager.Current.Profiles_FolderLocation = Location; and the restart.
There was a problem hiding this comment.
Fixed in a73415c — added ProfileManager.Save() before changing Profiles_FolderLocation in both ChangeLocationAction() and RestoreDefaultLocationActionAsync().
…h, fix doc comment Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Changes proposed in this pull request
Implements the same folder location management for Profiles that PR #3324 added for Settings: user-selectable location via UI, admin-enforced location via system-wide policy, with validation, restart-on-change, and graceful fallback.
Also renames policy/local-settings properties to follow the
Section_SettingNameconvention consistently.Profile location management (mirrors Settings implementation):
ProfileManager.GetProfilesFolderLocation()now resolves with priority: Policy → Custom user path → Default/PortableGetDefaultProfilesFolderLocation(),GetPortableProfilesFolderLocation(),ValidateProfilesFolderPath()with full error handlingSettingsInfo.Profiles_FolderLocationstores user-selected path (in main settings, not LocalSettingsInfo — settings file is already loaded when profile location is needed)PolicyInfo.Profiles_FolderLocationfor admin-enforced path viaconfig.jsonUI (SettingsProfilesView):
IsDefaultLocationrecalculated whenLocationchanges so the Restore Default button visibility stays in syncProperty renames:
SettingsFolderLocation→Settings_FolderLocation(PolicyInfo, LocalSettingsInfo, all references)ProfilesFolderLocation→Profiles_FolderLocation(PolicyInfo, all references)SettingsFolderLocationin LocalSettingsInfo via[JsonPropertyName]legacy propertyconfig.jsondeploymentsconfig.jsonexample:{ "Update_CheckForUpdatesAtStartup": false, "Settings_FolderLocation": "C:\\CustomPath\\NETworkManager\\Settings", "Profiles_FolderLocation": "C:\\CustomPath\\NETworkManager\\Profiles" }Related issue(s)
Based on PR #3324
Close #2787
Close #3208
Copilot generated summary
Copilot summary
This PR adds profile file location management matching the existing settings folder location feature from PR #3324. The
ProfileManager.GetProfilesFolderLocation()method now implements a three-tier priority system (policy override → custom user path → default/portable fallback) with comprehensive path validation. The Settings > Profiles UI is updated with an editable location textbox, browse/drag-drop support, change/restore buttons, and admin policy indicators. Profiles are explicitly saved before changing the folder location to prevent writes to the wrong path during app restart. Policy properties are renamed fromSettingsFolderLocation/ProfilesFolderLocationtoSettings_FolderLocation/Profiles_FolderLocationfor naming consistency, with backward-compatible deserialization for existing local settings files. Documentation updated across profiles.md, settings.md, system-wide-policies.md, and the changelog.To-Do
Contributing
By submitting this pull request, I confirm the following:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.